<template>
	<view>
		<view class="cu-custom" :style="[{height:CustomBar + 'px'}]">
			<view class="cu-bar fixed" :style="style" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor]">
				<view class="action" @tap="BackPage" v-if="isBack">
					<uni-icons type="back" color="#ffffff" size="25" />
					<!-- <slot name="backText"></slot> -->
				</view>
				<view class="content" :style="[{top:StatusBar + 'px'}]">
					<slot name="content"></slot>
				</view>
				<slot name="right"></slot>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: 45
			};
		},
		name: 'cu-custom',
		computed: {
			style() {
				var StatusBar = this.StatusBar;
				var CustomBar = this.CustomBar;
				var bgImage = this.bgImage;
				var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
				if (this.bgImage) {
					style = `${style}background-image:url(${bgImage});`;
				}
				return style
			}
		},
		mounted() {

			console.log('onLoad')
			console.log(this.CustomBar)
		},
		// m() {
		// 	console.log('onLoad')
		// 	console.log(this.bgColor)
		// },
		props: {
			bgColor: {
				type: String,
				default: ''
			},
			isBack: {
				type: [Boolean, String],
				default: false
			},
			bgImage: {
				type: String,
				default: ''
			},
		},
		methods: {
			BackPage() {
				// uni.navigateBack();
				history.go(-1);
			}
		}
	}
</script>

<style>
	.cu-custom {
		display: block;
		position: relative;
	}

	.cu-bar {
		display: flex;
		position: relative;
		align-items: center;
		/* height: 45px; */
		justify-content: space-between;
	}

	.cu-bar.fixed,
	.nav.fixed {
		position: fixed;
		width: 100%;
		top: 0;
		z-index: 996;
		box-shadow: 0 1upx 6upx rgba(0, 0, 0, 0.1);
	}

	.text-white,
	.line-white,
	.lines-white {
		color: #ffffff;
	}

	.action {
		/* padding-left: 5px; */
		width: 50px;
		text-align: center
	}

	.cuIcon-back:before {
		content: "\e5";
	}

	.content {
		position: absolute;
		left: 146upx;
		width: calc(100% - 96upx - 60upx - 120upx - 20upx);
		line-height: 1.1em;
		text-align: center;
		font-size: 18px;
	}

	.bg-img {
		background-size: cover;
		background-position: center;
		background-repeat: no-repeat;
	}

	.bg-gradual-blue {
		background-image: linear-gradient(45deg, #0081ff, #1cbbb4);
		color: #ffffff;
	}
</style>
